<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
  <div id="app">
    {{msg}}
    <my-com-a></my-com-a>
    <!-- <my-com-b></my-com-b> -->

  </div>
  <script>
    // 局部注册组件
    // 创建a组件
    let myComB = {
      data() {
        return {
          subMsg1: 'B组件'
        }
      },
      template: `
        <div>
          <span>{{subMsg1}}</span>
        </div>
      `
    };
    let myComA = {
      // 局部注册
      components: {
        'my-com-b': myComB
      },
      data() {
        return {
          subMsg: 'A组件'
        }
      },
      template: `
        <div>
          <my-com-b></my-com-b>
          <span>{{subMsg}}</span>
        </div>
      `
    };
    // 注册组件
    // Vue.component('my-com-a', myComA);
    // Vue.component('my-com-b',myComB);
    new Vue({
      components:{
        'my-com-a':myComA
      },
      el: "#app",
      data: {
        msg: '我是父组件'
      },
      methods: {

      }
    })
  </script>
</body>

</html>